<template>
  <div class="right3">
    <el-table
      :data="tableData"
      ref="tableRef"
      style="width: 100%"
      :max-height="tableH"
      @cell-click="rowClick"
      v-if="currentLevel === 1"
    >
      <!-- <el-table-column label="序号" prop="index" width="80" align="center">
      </el-table-column>
      <el-table-column label="区" prop="qu" align="center">
      </el-table-column>
      <el-table-column
        label="乡镇"
        prop="xzv"
        align="center"
        sortable
      ></el-table-column>
      <el-table-column
        label="村"
        prop="cunv"
        align="center"
        sortable
      ></el-table-column> -->
      <el-table-column
        v-for="(column, index) in columns"
        :key="index"
        :label="column.label"
        :prop="column.prop"
        :width="column.width"
        :align="column.align"
        :sortable="column.sortable"
      ></el-table-column>
    </el-table>
  </div>
</template>
<script setup>
import { onMounted, ref } from 'vue'
import { ElButton, ElIcon } from 'element-plus'
const props = defineProps({
  tableData: {
    type: Array,
    default: () => [],
  },
})

const tableH = ref('0px')
const tableRef = ref(null)
const getTableH = () => {
  setTimeout(() => {
    tableH.value = document.querySelector('.table-style').offsetHeight
    return `${tableH.value}px`
  }, 200)
}
const currentLevel = ref(1) // 1 是区县
const columns = [
  { label: '序号', prop: 'index', width: '80', align: 'center', sortable: false },
  { label: '区', prop: 'qu', width: '', align: 'center', sortable: false },
  { label: '乡镇', prop: 'xzv', width: '', align: 'center', sortable: true },
  { label: '村', prop: 'cunv', width: '', align: 'center', sortable: true },
]
onMounted(() => {
  getTableH()
  // createScroll()
})
</script>
<style scoped lang="scss">
.right3 {
  width: 100%;
  height: 100%;
  flex: 1;
  //   border: 1px solid red;
  // 表格部分样式
  // 最外层透明
  ::v-deep .el-table,
  ::v-deep .el-table__expanded-cell {
    background-color: transparent;
    color: #93dcfe;
    font-size: 2.2rem;
    border-bottom: 1px solid transparent; // 去掉表格体 的 边框
  }
  /* 表格内背景颜色  */
  ::v-deep .el-table {
    th,
    tr,
    td {
      background-color: transparent;
      border: none;
      color: #93dcfe;
      font-size: 2.2rem;
      // height: 5px;
      font-family: Source Han Sans CN Normal, Source Han Sans CN Normal-Normal;
      font-weight: Normal;
    }
  }
  ::v-deep .el-table__body-wrapper {
    .el-table__body {
      // border: 1px solid red;
      // background-color: red;
      .el-table__row {
        border: 10px solid red;
        // background-color: yellow;
      }
    }
  }
  /* // 设置表格行高度 */
  ::v-deep .el-table__body tr {
    padding: 0;
    height: 54px;
    border: 1px solid red;
  }

  /* // 修改高亮当前行颜色 */
  ::v-deep .el-table tbody tr:hover > td {
    background: #063570 !important;
  }

  /* // 取消当前行高亮 */
  //   ::v-deep .el-table tbody tr {
  //     pointer-events: none;
  //   }

  /* 修改表头样式-加边框 */
  //   ::v-deep .el-table__header-wrapper {
  //      border: solid 1px #04c2ed;
  //   }

  /* // 表格斑马自定义颜色 */
  ::v-deep .el-table__row.warning-row {
    background: #01205a;
  }

  /* 去掉表格里的padding */
  ::v-deep .el-table .cell,
  .el-table th div {
    padding-left: 0px;
    padding-right: 0px;
    padding-top: 0px;
    padding-bottom: 0px;
    font-size: 1.3rem;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}
/* 自定义内容样式 */
.content-color {
  color: #fff;
  cursor: pointer;
  text-decoration: underline;
}
.custom-column-style {
  color: red;
}
.back {
  display: flex;
  justify-content: flex-end;
}
</style>
